package org.edu.modules.kwgl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.edu.modules.kwgl.entity.VeJwBkJiankao;
import org.edu.modules.kwgl.entity.VeJwQkJiankao;
import org.edu.modules.kwgl.mapper.VeJwBkJiankaoMapper;
import org.edu.modules.kwgl.service.IVeJwBkJiankaoService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 补考监考
 * @Author: jeecg-boot
 * @Date:   2021-05-11
 * @Version: V1.0
 */
@Service
public class VeJwBkJiankaoServiceImpl extends ServiceImpl<VeJwBkJiankaoMapper, VeJwBkJiankao> implements IVeJwBkJiankaoService {

    @Override
    public List<Map> get2teacheridByQkid(int bkid) {
//        VeJwBkJiankao jiankao = baseMapper.selectOne(new QueryWrapper<VeJwBkJiankao>()
//                .eq("bkid", bkid)
//                .eq("type", 1));

        Map jiankao = baseMapper.getTeacherIdAndNameByBkid(bkid,1);

//        VeJwBkJiankao xunkao = baseMapper.selectOne(new QueryWrapper<VeJwBkJiankao>()
//                .eq("bkid", bkid)
//                .eq("type", 2));
        Map xunkao = baseMapper.getTeacherIdAndNameByBkid(bkid,2);
        Map<String,Object> defaultMap = new HashMap<>();
        defaultMap.put("teacherId","暂未安排");
        defaultMap.put("xm","暂未安排");
        List<Map> list = new ArrayList<>();
        if(jiankao!=null){
            list.add(jiankao);
        }else{

            list.add(defaultMap);
        }
        if(xunkao!=null){
            list.add(xunkao);
        }else {
            list.add(defaultMap);
        }

        return list;
    }

    @Override
    public List<VeJwBkJiankao> get2teacherByBkid(int bkid) {
        VeJwBkJiankao jiankao = baseMapper.selectOne(new QueryWrapper<VeJwBkJiankao>()
                .eq("bkid", bkid)
                .eq("type", 1));

        VeJwBkJiankao xunkao = baseMapper.selectOne(new QueryWrapper<VeJwBkJiankao>()
                .eq("bkid", bkid)
                .eq("type", 2));

        List<VeJwBkJiankao> list = new ArrayList<>();
        if(jiankao!=null){
            list.add(jiankao);
        }else{
            list.add(null);
        }
        if(xunkao!=null){
            list.add(xunkao);
        }else {
            list.add(null);
        }
        return list;
    }
}
